package com.hopes.bizz.risk.statistic.controller;

import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.hopes.bizz.risk.control.service.RiskMeasureTaskService;
import com.hopes.bizz.risk.statistic.dto.SafetyStatisticsDTO;
import com.hopes.bizz.risk.statistic.serivce.SafetyStatisticsService;
import com.hopes.bizz.risk.statistic.vo.SafetyStatisticsExcelVO;
import com.hopes.boss.common.core.util.R;
import com.hopes.boss.common.excel.annotation.ResponseExcel;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.security.SecurityRequirement;
import io.swagger.v3.oas.annotations.tags.Tag;
import lombok.RequiredArgsConstructor;
import org.springframework.http.HttpHeaders;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * @author daijie
 * @version 1.0
 * @date 2023/8/1 15:41
 * @Description:
 */
@RestController
@RequiredArgsConstructor
@RequestMapping("/safetyStatistics" )
@Tag(description = "safetyStatistics" , name = "安全包保管理" )
@SecurityRequirement(name = HttpHeaders.AUTHORIZATION)
public class SafetyStatisticsController {

    private final RiskMeasureTaskService riskMeasureTaskService;

    private final SafetyStatisticsService safetyStatisticsService;

    @GetMapping(value = "page")
    @Operation(summary = "安全包保履职情况统计" , description = "安全包保履职情况统计" )
    @PreAuthorize("@pms.hasPermission('risk_safety_statistics_view')" )
    public R list(Page page, SafetyStatisticsDTO safetyStatistics) {
        return R.ok(riskMeasureTaskService.taskStatistics(page, safetyStatistics));
    }

    /**
     * 导出
     */
    @ResponseExcel
    @GetMapping(value = "export")
    @PreAuthorize("@pms.hasPermission('risk_safety_statistics_export')" )
    public List<SafetyStatisticsExcelVO> export(SafetyStatisticsDTO dto) {
        return safetyStatisticsService.exportExcel(dto);
    }
}
